package lili.com.my.activity;


import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import lili.com.my.R;
import lili.com.my.fragment.CourseFragment;
import lili.com.my.fragment.ExerciseFragment;
import lili.com.my.fragment.MyFragment;

public class MainActivity extends AppCompatActivity {

    private FragmentManager fragmentManager;
    private FragmentTransaction fragmentTransaction;
    private ImageView courseImg;
    private ImageView exerciseImg;
    private ImageView myImg;
    private TextView textViewCourse;
    private TextView textViewexercises;
    private TextView textViewmy;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        courseImg = (ImageView) findViewById(R.id.couse_img);
        exerciseImg = (ImageView) findViewById(R.id.exercises_img);
        myImg = (ImageView) findViewById(R.id.my_img);
        textViewCourse = (TextView) findViewById(R.id.couse);
        textViewexercises = (TextView) findViewById(R.id.exercises);
        textViewmy = (TextView) findViewById(R.id.my);
        fragmentManager = getFragmentManager();
        fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.add(R.id.fragment, new CourseFragment());
        fragmentTransaction.commit();

    }

    public void course(View view) {
        courseImg.setImageResource(R.drawable.main_course_icon_selected);
        textViewCourse.setTextColor(Color.parseColor("#ACCCF4"));
        exerciseImg.setImageResource(R.drawable.main_exercises_icon);
        textViewexercises.setTextColor(Color.parseColor("#9C9C9C"));
        myImg.setImageResource(R.drawable.main_my_icon);
        textViewmy.setTextColor(Color.parseColor("#9C9C9C"));
        fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.fragment, new CourseFragment());
        fragmentTransaction.commit();
    }

    public void exercise(View view) {
        courseImg.setImageResource(R.drawable.main_course_icon);
        textViewCourse.setTextColor(Color.parseColor("#9C9C9C"));
        exerciseImg.setImageResource(R.drawable.main_exercises_icon_selected);
        textViewexercises.setTextColor(Color.parseColor("#ACCCF4"));
        myImg.setImageResource(R.drawable.main_my_icon);
        textViewmy.setTextColor(Color.parseColor("#9C9C9C"));
        fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.fragment, new ExerciseFragment());
        fragmentTransaction.commit();
    }

    public void my(View view) {
        courseImg.setImageResource(R.drawable.main_course_icon);
        textViewCourse.setTextColor(Color.parseColor("#9C9C9C"));
        exerciseImg.setImageResource(R.drawable.main_exercises_icon);
        textViewexercises.setTextColor(Color.parseColor("#9C9C9C"));
        myImg.setImageResource(R.drawable.main_my_icon_selected);
        textViewmy.setTextColor(Color.parseColor("#ACCCF4"));
        fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.fragment, new MyFragment());
        fragmentTransaction.commit();
    }
}